﻿using Pay.Core;
using Pay.DTO;
using Pay.IService;
using Pay.TO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Pay.Web.Areas.Admin.Controllers
{
    [RouteArea("admin")]
    [RoutePrefix("shopInfo")]
    public class ShopInfoController : AdminController
    {
        private IShopInfoService _iShopInfoService;

        public ShopInfoController(IShopInfoService iShopInfoService)
        {
            _iShopInfoService = iShopInfoService;
        }

        public ActionResult Index()
        {
            return View();
        }

        public JsonResult Gets(ShopInfoQuery query)
        {
            var model = _iShopInfoService.GetShopInfos(query);
            return Json(ResultToJson.Json(model), JsonRequestBehavior.AllowGet);
        }

        public JsonResult Get(long id)
        {
            var model = _iShopInfoService.GetShopInfoById(id);
            return Json(ResultToJson.Json(model), JsonRequestBehavior.AllowGet);
        }

        [HttpPost]
        public JsonResult UpdateStatus(long id, int status)
        {
            var result = _iShopInfoService.UpdateShopInfoStatus(id, status);
            return Json(ResultToJson.Json(result > 0 ? " 修改成功" : "修改失败", result));
        }

        [HttpPost]
        public JsonResult UpdateShopInfo(shop_info_dto_ex dto) {
            var result = _iShopInfoService.UpdateShopInfo(dto);
            return Json(ResultToJson.Json(result ? " 修改成功" : "未做任何修改", result));
        }

    }
}